
class P524_39643 {

	static boolean[] primes = {false, false, true, true, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false};
//	private static StringBuffer sb;
	
	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}


	public static void main(String[] args) {
		
		String line = readLn();
		
		int cases = 1;
		
//		sb = new StringBuffer();
		
		while (line != null) {
			System.out.println("Case " + cases + ":");
			cases++;
			int[] solution = new int[Integer.parseInt(line)];
			solution[0] = 1;
			process(solution, 1);
//			System.out.print(sb.toString());
//			sb = new StringBuffer();
			
			line = readLn();
			
			if (line != null) System.out.println();
			
		}
		
	}
	
	static void process(int[] solution, int index) {
//		System.out.println("index: " + index);
//		System.out.println(Arrays.toString(solution));
		if (index == solution.length) {
			print(solution);
		} else {
			
			for (int k = 2; k <= solution.length; k++) {
				if (isValid(solution, index, k)) {
					solution[index] = k;
					process(solution, index + 1);
				}
			}
			
		}
		
	}


	private static void print(int[] solution) {
		StringBuffer sb = new StringBuffer();
		for (int k = 0; k < solution.length; k++) {
			sb.append(solution[k]);
			if (k + 1 != solution.length) sb.append(' ');
		}
		System.out.println(sb.toString());
	}


	private static boolean isValid(int[] solution, int index, int num) {
		
		for (int i = 0; i < index; i++) {
			if (solution[i] == num) return false;
		}
		
		if (index == solution.length - 1) {
			if (isPrime(num + solution[index-1]) && isPrime(num + solution[0])) return true;
		} else if (isPrime(num + solution[index - 1])) return true;
		
		return false;
	}


	private static boolean isPrime(int i) {
		return primes[i];
	}
	
}
